<!--batas-->
<?php if( ($this->session->userdata('user_pos')==$this->config->item('se')) ):?> 
<div class="column full fl">
  
        <div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?='New Prospect';?></h2>
			
			<div class="box-content box-table">
			
            <?php echo $this->session->flashdata('messagex'); ?>
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                       <th><?php echo $this->lang->line('date'); ?></th>
					   <th><?php echo $this->lang->line('cust_name'); ?></th>
					   <th class="tc"><?php echo $this->lang->line('pic'); ?></th>
					   <th class="tc"><?php echo $this->lang->line('action'); ?></th>
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                    <?php $i=1; ?>
					<?php foreach($table['clients'] as $rec): ?>
					<?php //if($rec['status_id']==$this->config->item('prospect')):?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?php echo $rec['date_stamp']; ?>
						</td>
						<td >
							<h5><?php echo $rec['customer_name']; ?></h5>
						</td>
						
						<td >
							<h5>
							<?php if($rec['rev']):
								echo $rec['rev'];
							?>
							<?php elseif($rec['rev2']):
								echo $rec['rev2'];
							?>
							<?php elseif($rec['rev3']):
								echo $rec['rev3'];
								endif;
							?>
							
							
							</h5>
						</td>
						
						<td >
							<h5>
							<?=anchor('dashboard/crm/updateProspect/'.$rec['id'],'Approve');?>|
							<?=anchor('dashboard/crm/updateReject/'.$rec['id'],'Reject');?>
							</h5>
						</td>
						
					</tr>
                    
					<tr class="odd openable-tr">
						
                        <td colspan="4">
							<div class="fl typo">
							<b><?php $this->config->item('customer'); ?></b>
							<p class="p_justify">
                              <?php echo $rec['tlp']; ?>
							</p>
							<div class="s_3"></div>
							<p class="p_justify">
                              <?php echo $rec['pic']; ?>
							</p>
							</div>
						   <!--
							<div class="fr">
								 <input id="validate" class="button themed" type="submit" value="<?php echo $this->lang->line('save');?>" name="save" />
							</div>
						   -->
						<div class="clear"></div>
						</td>
					</tr>
                    <?php $i++; 
					///endif;
					endforeach;?>
				</tbody>
			</table>
			</div>
		</div>
       	  
 </div>
 <?php endif;?>
 

<!--batas-->
<?php if( ($this->session->userdata('user_pos')==$this->config->item('spv')) || ($this->session->userdata('user_pos')==$this->config->item('mgr')) ):?> 
<div class="column half fl">		
		<div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?='New Data from In House';?></h2>
			
			<div class="box-content box-table">
			
            <?php echo $this->session->flashdata('message'); ?>
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                       <th><?php echo $this->lang->line('date'); ?></th>
					   <th><?php echo $this->lang->line('cust_name'); ?></th>
					   <th class="tc"><?php echo $this->lang->line('pic'); ?></th>
					   <th class="tc"><?php echo $this->lang->line('action'); ?></th>
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                    <?php $i=1; ?>
					<?php foreach($table['client_inhouse'] as $rec): ?>
					<?php if(($rec['rev3']=='') ):?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?php echo $rec['date_stamp']; ?>
						</td>
						<td >
							<h5><?php echo $rec['customer_name']; ?></h5>
						</td>
						
						<td >
							<h5>
							<?php if($rec['rev']):
								echo $rec['rev'];
							?>
							
							<?php elseif($rec['rev2']):
								echo $rec['rev2'];
							?>
							
							<?php elseif($rec['rev3']):
								echo $rec['rev3'];
								endif;
							?>
							</h5>
						</td>
						
						<td >
							<h5>
							<?=anchor('dashboard/crm/updateProspect/'.$rec['id'],'Approve');?>|
							<?=anchor('dashboard/crm/updateReject/'.$rec['id'],'Reject');?>
							</h5>
						</td>
						
					</tr>
					
					
					<tr class="odd openable-tr">
						
                        <td colspan="4">
							<div class="fl typo">
							<b><?php $this->config->item('customer'); ?></b>
							<p class="p_justify">
                              <?php echo $rec['tlp']; ?>
							</p>
							<div class="s_3"></div>
							<p class="p_justify">
                              <?php echo $rec['pic']; ?>
							</p>
							</div>
						   <!--
							<div class="fr">
								 <input id="validate" class="button themed" type="submit" value="<?php echo $this->lang->line('save');?>" name="save" />
							</div>
						   -->
						<div class="clear"></div>
						</td>
					</tr>
                    <?php $i++; 
					endif;
					endforeach;?>
					
					<?php if(COUNT($table['client_inhouse'])):?>
					<tr class="odd">
						<td class="tc">
							
						</td>
						<td >
							<h5>
							<?=anchor('dashboard/crm/updateAll/HOUSE','Approve All');?>
							<?php //anchor('dashboard/crm/updateReject/All/'In House','Reject All');?>
							</h5>
						</td>
						
						<td >
							
						</td>
						
						<td >
							
						</td>
						
					</tr>
					<?php endif;?>
                    
					
				</tbody>
			</table>
			</div>
		</div>
       	  
 </div>
 
 <!-- Batas -->
 
 <div class="column half fr">

		<div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?='New Data from DNA';?></h2>
			
			<div class="box-content box-table">
			
            <?php echo $this->session->flashdata('message'); ?>
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                       <th><?php echo $this->lang->line('date'); ?></th>
					   <th><?php echo $this->lang->line('cust_name'); ?></th>
					   <th class="tc"><?php echo $this->lang->line('pic'); ?></th>
					   <th class="tc"><?php echo $this->lang->line('action'); ?></th>
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                    <?php $i=1; ?>
					<?php foreach($table['client_dna'] as $rec): ?>
					<?php if(($rec['rev']=='') ):?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?php echo $rec['date_stamp']; ?>
						</td>
						<td >
							<h5><?php echo $rec['customer_name']; ?></h5>
						</td>
						
						<td >
							<h5>
							<?php if($rec['rev']):
								echo $rec['rev'];
							?>
							
							<?php elseif($rec['rev2']):
								echo $rec['rev2'];
							?>
							
							<?php elseif($rec['rev3']):
								echo $rec['rev3'];
								endif;
							?>
							</h5>
						</td>
						
						<td >
							<h5>
							<?=anchor('dashboard/crm/updateProspect/'.$rec['id'],'Approve');?>|
							<?=anchor('dashboard/crm/updateReject/'.$rec['id'],'Reject');?>
							</h5>
						</td>
						
					</tr>
					
					
					
					<tr class="odd openable-tr">
						
                        <td colspan="4">
							<div class="fl typo">
							<b><?php $this->config->item('customer'); ?></b>
							<p class="p_justify">
                              <?php echo $rec['tlp']; ?>
							</p>
							<div class="s_3"></div>
							<p class="p_justify">
                              <?php echo $rec['pic']; ?>
							</p>
							</div>
						   <!--
							<div class="fr">
								 <input id="validate" class="button themed" type="submit" value="<?php echo $this->lang->line('save');?>" name="save" />
							</div>
						   -->
						<div class="clear"></div>
						</td>
					</tr>
                    <?php $i++; 
					endif;
					endforeach;?>
					
					<?php if(COUNT($table['client_dna'])>0):?>
					<tr class="even">
						<td class="tc">
							
						</td>
						<td >
							<h5>
							<?=anchor('dashboard/crm/updateAll/DNA','Approve All');?>
							<?php //anchor('dashboard/crm/updateReject/All/DNA','Reject All');?>
							</h5>
						</td>
						
						<td >
							
						</td>
						
						<td >
							<h5>
							
							</h5>
						</td>
						
					</tr>
					<?php endif;?>
                    
				</tbody>
			</table>
			</div>
		</div>
       	  
 </div>
  <?php endif;?>
  
  
  <?php if( ($this->session->userdata('user_pos')==$this->config->item('spv')) || ($this->session->userdata('user_pos')==$this->config->item('mgr')) ):?> 
	<div class="column full fl">
		<div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?='Prospect to Existing';?></h2>
			
			<div class="box-content box-table">
			
            <?php echo $this->session->flashdata('message'); ?>
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                       <th><?php echo $this->lang->line('date'); ?></th>
					   <th><?php echo $this->lang->line('cust_name'); ?></th>
					   <th class="tc"><?php echo $this->lang->line('pic'); ?></th>
					   <th class="tc"><?php echo $this->lang->line('action'); ?></th>
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                    <?php $i=1; ?>
					<?php foreach($table['clientx'] as $rec): ?>
					<?php //if($rec['status_id']==$this->config->item('prospect')):?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?php echo $rec['date_stamp']; ?>
						</td>
						<td >
							<h5><?php echo $rec['customer_name']; ?></h5>
						</td>
						
						<td >
							<h5>
							<?php if($rec['rev']):
								echo $rec['rev'];
							?>
							
							<?php elseif($rec['rev2']):
								echo $rec['rev2'];
							?>
							
							<?php elseif($rec['rev3']):
								echo $rec['rev3'];
								endif;
							?>
							</h5>
						</td>
						
						<td >
							<h5>
							<?=anchor('dashboard/crm/updateExisting/'.$rec['id'],'Approve');?>|
							<?=anchor('dashboard/crm/updateRejectExisting/'.$rec['id'],'Reject');?>
							</h5>
						</td>
						
					</tr>
                    
					<tr class="odd openable-tr">
						
                        <td colspan="4">
							<div class="fl typo">
							<b><?php $this->config->item('customer'); ?></b>
							<p class="p_justify">
                              <?php echo $rec['tlp']; ?>
							</p>
							<div class="s_3"></div>
							<p class="p_justify">
                              <?php echo $rec['pic']; ?>
							</p>
							</div>
						   <!--
							<div class="fr">
								 <input id="validate" class="button themed" type="submit" value="<?php echo $this->lang->line('save');?>" name="save" />
							</div>
						   -->
						<div class="clear"></div>
						</td>
					</tr>
                    <?php $i++; 
					///endif;
					endforeach;?>
				</tbody>
			</table>
			
			</div>
		</div>
	</div>
  <?php endif;?>
		


<?php if( ($this->session->userdata('user_group')<>$this->config->item('admin'))):?>
<div class="column full fl">

        <div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?php echo 'Status Update'; ?></h2>
			
			<div class="box-content box-table">
			
            <?php echo $this->session->flashdata('message'); ?>
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                       <th><?php echo $this->lang->line('date'); ?></th>
                       <th><?php echo $this->lang->line('time'); ?></th>
                       <th><?php echo $this->lang->line('activity'); ?></th>
					   <th><?php echo $this->lang->line('cust_name'); ?></th>
                       <th><?php echo $this->lang->line('location'); ?></th>
                       <th><?php echo $this->lang->line('people'); ?></th>
                       <th><?php echo $this->lang->line('objective');?></th>
                       <th><?php echo $this->lang->line('result');?></th>
                       <th><?php echo $this->lang->line('follow_up');?></th>
					   <?php if(($this->session->userdata('user_pos')== $this->config->item('spv')) || ($this->session->userdata('user_pos')== $this->config->item('mgr')) ):?>
							<th>
							<?php echo $this->lang->line('pic');?>
							</th>
						<?php endif;?>
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                    <?php $i=1; ?>
					<?php foreach($table['customers'] as $rec): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?php echo $rec['activity_date']; ?>
						</td>
                        <td class="tc">
							<?php echo $rec['activity_time']; ?>
						</td>
                        <td class="tc">
							<?php echo $rec['activity_type']; ?>
						</td>
						<td >
							<h5><?php echo $rec['customer_name']; ?></h5>
						</td>
                        <td >
							<h5><?php echo $rec['activity_location']; ?></h5>
						</td>
                        <td >
							<h5><?php echo $rec['activity_people']; ?></h5>
						</td>
                        <td >
							<h5><?php echo $rec['activity_objective']; ?></h5>
						</td>
                        <td >
							<h5><?php echo $rec['activity_result']; ?></h5>
						</td>
                        <td >
							<h5><?php echo $rec['activity_follow_up']; ?></h5>
						</td>
						<?php if(($this->session->userdata('user_pos')== $this->config->item('spv')) || ($this->session->userdata('user_pos')== $this->config->item('mgr')) ):?>
							<td>
							<h5><?php echo $rec['pic']; ?></h5>
							</td>
						<?php endif;?>
					</tr>
                    
					<tr class="odd openable-tr">
						
                        <td colspan="4">
							<div class="fl typo">
							<b><?php $this->config->item('customer'); ?></b>
							<p class="p_justify">
                              <?php echo $rec['tlp']; ?>
							</p>
							<div class="s_3"></div>
							<p class="p_justify">
                              <?php echo $rec['pic']; ?>
							</p>
							</div>
						   <!--
							<div class="fr">
								 <input id="validate" class="button themed" type="submit" value="<?php echo $this->lang->line('save');?>" name="save" />
							</div>
						   -->
						<div class="clear"></div>
						</td>
					</tr>
                    <?php $i++; endforeach;?>
				</tbody>
			</table>
			</div>
		</div>
       
    </div>

<?php endif;?>



<!-- Monitoring SE -->
<?php if( ($this->session->userdata('user_pos')==$this->config->item('se'))):?>
<div class="column full fl">
<?=form_open('dashboard/crm/periode',array('name'=>'frmActivity'));?>
        <div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?php echo 'Monitoring SE'; ?>
        <?=form_dropdown('periode',array('day'=>'Per Day','month'=>'Per Month','3month'=>'Per 3 Month'),$this->session->userdata('periode'),'onChange="frmActivity.submit()"');?>
        </h2>
			
			<div class="box-content box-table">
			
            <?php echo $this->session->flashdata('message'); ?>
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                      <?php if(!$this->session->userdata('periode')): ?>  
                       <th><?='Date'; ?></th>
                      <?php else:?>
                      <th><?='Month'; ?></th>
                      <?php endif;?>
                 
                       <th><?='Call'; ?></th>
                       <th><?='Meeting'?></th>
					   <th><?='Follow Up';?></th>
                       <th><?='Invalid Data';?></th>
					   <th><?='Total';?></th>
                       <th><?='Presentasi Expertise (%)';?></th>
				</thead>
				
				<tbody class="openable-tbody">
                <?php if(!$this->session->userdata('periode')): ?>
                    <?php $i=1; ?>
					<?php foreach($table['activityperiode'] as $rec): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?=$rec['activity_date']; ?>
						</td>
                        <td class="tc">
							<?=$rec['calls']; ?>
						</td>
                        <td class="tc">
							<?=$rec['meeting']; ?>
						</td>
                        <td class="tc">
							<?=$rec['fu']; ?>
						</td>
                        <td class="tc">
							<?=$rec['invalid']; ?>
						</td>
						
						<td class="tc">
							<?=$rec['calls']+$rec['meeting']+$rec['fu']+$rec['invalid'];?>
						</td>
                        
                        <td class="tc">
							<?php $total=(($rec['meeting']/$rec['fu']+$rec['meeting'])) * 100;?>
							<?php 
								if($total!=0)
									echo $total;
								else
									echo '0';
							?>
						</td>
                        
					</tr>
                    <?php $i++; endforeach;?>
                <?php elseif($this->session->userdata('periode')=='month'): ?> 
                    <?php $i=1; ?>
					<?php foreach($table['activityperiodeM'] as $rec): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?=$rec['monthly']; ?>
						</td>
                        <td class="tc">
							<?=$rec['calls']; ?>
						</td>
                        <td class="tc">
							<?=$rec['meeting']; ?>
						</td>
                        <td class="tc">
							<?=$rec['fu']; ?>
						</td>
                        <td class="tc">
							<?=$rec['invalid']; ?>
						</td>
                        
                        <td class="tc">
							<?=$rec['calls']+$rec['meeting']+$rec['fu']+$rec['invalid'];?>
						</td>
                        
                        <td class="tc">
							<?=(($rec['meeting']/$rec['fu']+$rec['meeting']))*100;?>
						</td>
                        
					</tr>
                 <?php $i++; endforeach;?> 
                 <?php elseif($this->session->userdata('periode')=='3month'): ?> 
                  <?php //$i=1; ?>
					<?php //foreach($table['activityperiodeM'] as $rec): ?>
                    <?php //if($i % 2 == 0): 
                           // $zebra="odd";
                          //else: 
                           // $zebra="even";
                          //endif;
                    ?>
                    <?php if(date('m')<= '03'):?>
                    <tr class="odd">
						<td class="tc">
							<?='Januari - Maret';?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth0103'])?>
							<?=$table['activityMonth0103']['calls']; ?>
						</td>
                        <td class="tc">
                             <?php if($table['activityMonth0103'])?>
							<?=$table['activityMonth0103']['meeting']; ?>
						</td>
                        <td class="tc">
                             <?php if($table['activityMonth0103'])?>
							<?=$table['activityMonth0103']['fu']; ?>
						</td>
                        <td class="tc">
                             <?php if($table['activityMonth0103'])?>
							<?=$table['activityMonth0103']['invalid']; ?>
						</td>
                        
                        <td class="tc">
							<?=$table['activityMonth0103']['calls']+$table['activityMonth0103']['meeting']+$table['activityMonth0103']['fu']+$table['activityMonth0103']['invalid'];?>
						</td>
                        
                        <td class="tc">
							<?=(($table['activityMonth0103']['meeting']/$table['activityMonth0103']['fu']+$table['activityMonth0103']['meeting']))*100;?>
						</td>
                        
					</tr>
                    <?php endif?>
                    
                    <?php if(date('m')>= '04'):?>
                    <tr class="even">
						<td class="tc">
							<?='April - Juni';?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth0406'])?>
							<?=$table['activityMonth0406']['calls']; ?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth0406'])?>
							<?=$table['activityMonth0406']['meeting']; ?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth0406'])?>
							<?=$table['activityMonth0406']['fu']; ?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth0406'])?>
							<?=$table['activityMonth0406']['invalid']; ?>
						</td>
                        
                        <td class="tc">
                            <?php if($table['activityMonth0406'])?>
							<?=(($table['activityMonth0406']['meeting']+$table['activityMonth0406']['fu'])/2)*100;?>
						</td>
                        
					</tr>
                    <?php endif;?>
                    
                    <?php if(date('m')>= '07'):?>
                    <tr class="odd">
						<td class="tc">
							<?='Juli - September';?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth0709'])?>
							<?=$table['activityMonth0709']['calls']; ?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth0709'])?>
							<?=$table['activityMonth0709']['meeting']; ?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth0709'])?>
							<?=$table['activityMonth0709']['fu']; ?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth0709'])?>
							<?=$table['activityMonth0709']['invalid']; ?>
						</td>
                        
                        <td class="tc">
                            <?php if($table['activityMonth0709'])?>
							<?=(($table['activityMonth0709']['meeting']+$table['activityMonth0709']['fu'])/2)*100;?>
						</td>
                        
					</tr>
                    <?php endif;?>
                    
                    
                    <?php if(date('m')>= '10'):?>
                    <tr class="even">
						<td class="tc">
							<?='Oktober - December';?>
						</td>
                        <td class="tc">
                            <?php if($table['activityMonth1012'])?>
							<?=$table['activityMonth1012']['calls']; ?>
						</td>
                        <td class="tc">
                             <?php if($table['activityMonth1012'])?>
							<?=$table['activityMonth1012']['meeting']; ?>
						</td>
                        <td class="tc">
                             <?php if($table['activityMonth1012'])?>
							<?=$table['activityMonth1012']['fu']; ?>
						</td>
                        <td class="tc">
                             <?php if($table['activityMonth1012'])?>
							<?=$table['activityMonth1012']['invalid']; ?>
						</td>
                        
                        <td class="tc">
                             <?php if($table['activityMonth1012'])?>
							<?=(($table['activityMonth1012']['meeting']+$table['activityMonth1012']['fu'])/2)*100;?>
						</td>
                        
                        
					</tr>
                    <?php endif;?>
                    
                <?php endif;?>   
				</tbody>
			</table>
			</div>
		</div>
       
    </div>
<?=form_close();?>
<?php endif;?>
<!-- End Of Monitoring -->


<!-- Monitoring SE For SPV -->
<?php if( ($this->session->userdata('user_pos')==$this->config->item('spv'))):?>
<div class="column full fl">
<?=form_open('dashboard/crm/periode',array('name'=>'frmActivity'));?>
        <div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?php echo 'Monitoring SE'; ?>
        <?=form_dropdown('periode',array('day'=>'Per Day','month'=>'Per Month','3month'=>'Per 3 Month'),$this->session->userdata('periode'),'onChange="frmActivity.submit()"');?>
        <?=anchor('dashboard/crm/exportse/'.$this->session->userdata('periode'),'Export to Excel','style="color:#FFF"'); ?>
		</h2>
			
			<div class="box-content box-table">
			
            <?php echo $this->session->flashdata('message'); ?>
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                      <?php if(!$this->session->userdata('periode')): ?>  
                       <th><?='Date'; ?></th>
                      <?php else:?>
                      <th><?='Month'; ?></th>
                      <?php endif;?>
                       
                       <th><?='SE Name'; ?></th>
                       <th><?='Call'; ?></th>
                       <th><?='Meeting'?></th>
					   <th><?='Follow Up';?></th>
                       <th><?='Invalid Data';?></th>
					   <th><?='Total';?></th>
                       <th><?='Presentasi Expertise (%)';?></th>
				</thead>
				
				<tbody class="openable-tbody">
                <?php if(!$this->session->userdata('periode')): ?>
                    <?php $i=1; ?>
					<?php foreach($table['activityperiode'] as $rec): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?=$rec['activity_date']; ?>
						</td>
                        
						<td class="tc">
							<?=$rec['pic']; ?>
						</td>
                        
						<td class="tc">
							<?=$rec['calls']; ?>
						</td>
                        
						<td class="tc">
							<?=$rec['meeting']; ?>
						</td>
                        
						<td class="tc">
							<?=$rec['fu']; ?>
						</td>
						
                        <td class="tc">
							<?=$rec['invalid']; ?>
						</td>
						
						<td class="tc">
							<?=$rec['calls']+$rec['meeting']+$rec['fu']+$rec['invalid'];?>
						</td>
                        
                        <td class="tc">
							<?php if($rec['fu']==0): ?>
							0	
							<?php else: ?>
							<?=(($rec['meeting']/$rec['fu']+$rec['meeting']))*100;?>
							<?php endif?>
						</td>
                        
					</tr>
                    <?php $i++; endforeach;?>
                <?php elseif($this->session->userdata('periode')=='month'): ?> 
                    <?php $i=1; ?>
					<?php foreach($table['activityperiodeM'] as $rec): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?=$rec['monthly']; ?>
						</td>
                        
                        <td class="tc">
							<?=$rec['pic']; ?>
						</td>
                        
                        <td class="tc">
							<?=$rec['calls']; ?>
						</td>
                        
						<td class="tc">
							<?=$rec['meeting']; ?>
						</td>
                        
						<td class="tc">
							<?=$rec['fu']; ?>
						</td>
						
                        <td class="tc">
							<?=$rec['invalid']; ?>
						</td>
						
						<td class="tc">
							<?=$rec['calls']+$rec['meeting']+$rec['fu']+$rec['invalid'];?>
						</td>
                        
                        <td class="tc">
							<?php if($rec['fu']==0):?>
								0
							<?php else: ?>
							<?=(($rec['meeting']/$rec['fu']+$rec['meeting']))*100;?>
							<?php endif?>
						</td>
                        
					</tr>
                 <?php $i++; endforeach;?> 
                 <?php elseif($this->session->userdata('periode')=='3month'): ?> 
                    <?php if(date('m')<= '03'):?>
                    <?php 
                        $x=1;
                        foreach($table['se'] as $se):?>
                    <?php $val=$this->dashboards->activity3Month('01','03',$se['username']);?>
                    <tr class="odd">
						<td class="tc">
                            <?php if($x==1):?>
							 <?='Januari - Maret';?>
                             <?php endif;?>
						</td>
                        
                        <td class="tc">
							<?=$se['username']; ?>
						</td>
                        
                        <td class="tc">
                            <?php if($val)?>
							<?=$val['calls']; ?>
						</td>
                        <td class="tc">
                             <?php if($val)?>
							<?=$val['meeting']; ?>
						</td>
                        <td class="tc">
                             <?php if($val)?>
							<?=$val['fu']; ?>
						</td>
						
						<td class="tc">
                             <?php if($val)?>
							<?=$val['invalid']; ?>
						</td>
                        
						<td class="tc">
                             <?php if($val)?>
							<?=$val['calls']+$val['fu']+$val['invalid']+$val['meeting']; ?>
						</td>
						
                        <td class="tc">
                            <?php if($val['fu']==0) : ?>
								0
							<?php else: ?>
							<?=(($val['meeting']/$val['fu']+$val['meeting']))*100;?>
							<?php endif?>
						</td>
                        
					</tr>
                    <?php $x++; endforeach;?>
                    <?php endif?>
                    
                    <?php if(date('m')>= '04'):?>
                    <?php foreach($table['se'] as $se):?>
                    <?php $val=$this->dashboards->activity3Month('04','06',$se['username']);?>
                    <tr class="even">
						<td class="tc">
							<?='April - Juni';?>
						</td>
                       <td class="tc">
                            <?php if($val)?>
							<?=$val['calls']; ?>
						</td>
                        <td class="tc">
                             <?php if($val)?>
							<?=$val['meeting']; ?>
						</td>
                        
						<td class="tc">
                             <?php if($val)?>
							<?=$val['fu']; ?>
						</td>
						
                        <td class="tc">
                             <?php if($val)?>
							<?=$val['invalid']; ?>
						</td>
						
						<td class="tc">
                             <?php if($val)?>
							<?=$val['calls']+$val['meeting']+$val['fu']+$val['invalid']; ?>
						</td>
                        
                         <td class="tc">
                           <?php if($val['fu']!=0):?>
							0
						   <?php else: ?>
							<?=(($val['meeting']/$val['fu']+$val['meeting']))*100;?>
							<?php endif?>
						</td>
						
					</tr>
                    <?php endforeach;?>
                    <?php endif;?>
                    
                    <?php if(date('m')>= '07'):?>
                    <?php foreach($table['se'] as $se):?>
                    <?php $val=$this->dashboards->activity3Month('07','09',$se['username']);?>
                    <tr class="odd">
						<td class="tc">
							<?='Juli - September';?>
						</td>
                        
						<td class="tc">
                            <?php if($val)?>
							<?=$val['calls']; ?>
						</td>
                        
						<td class="tc">
                             <?php if($val)?>
							<?=$val['meeting']; ?>
						</td>
                        
						<td class="tc">
                             <?php if($val)?>
							<?=$val['fu']; ?>
						</td>
						
                        <td class="tc">
                             <?php if($val)?>
							<?=$val['invalid']; ?>
						</td>
						
						<td class="tc">
                             <?php if($val)?>
							<?=$val['calls']+$val['meeting']+$val['fu']+$val['invalid']; ?>
						</td>
                        
                        <td class="tc">
                            <?php if($val['fu']!=0):?>
								0
							<?php else:?>
							<?=(($val['meeting']/$val['fu']+$val['meeting']))*100;?>
							<?php endif;?>
						</td>
                        
					</tr>
                    <?php endforeach;?>
                    <?php endif;?>
                    
                    
                    <?php if(date('m')>= '10'):?>
                    <?php foreach($table['se'] as $se):?>
                    <?php $val=$this->dashboards->activity3Month('10','12',$se['username']);?>
                    <tr class="even">
						<td class="tc">
							<?='Oktober - December';?>
						</td>
                        
						<td class="tc">
                            <?php if($val)?>
							<?=$val['calls']; ?>
						</td>
                        
						<td class="tc">
                             <?php if($val)?>
							<?=$val['meeting']; ?>
						</td>
                        
						<td class="tc">
                             <?php if($val)?>
							<?=$val['fu']; ?>
						</td>
						
                        <td class="tc">
                             <?php if($val)?>
							<?=$val['invalid']; ?>
						</td>
                        
						 <td class="tc">
                        
							<?=$val['calls']+$val['meeting']+$val['fu']+$val['invalid'];?>
						</td>
						
                        <td class="tc">
                           <?php if($val['fu']!=0):?>
						   0
						   <?php else: ?>
							<?=(($val['meeting']/$val['fu']+$val['meeting']))*100;?>
							<?php endif;?>
						</td>
                        
					</tr>
                   <?php endforeach;?>
                <?php endif;?>
                   
                <?php endif;?>
				</tbody>
			</table>
			</div>
		</div>
       
    </div>
<?=form_close();?>
<?php endif;?>
<!-- End Of Monitoring -->


<!-- Performance TA -->

<?php if( ($this->session->userdata('user_group')<>$this->config->item('admin'))):?>
<?=form_open('dashboard/crm/performance','name="frmPerformance"');?>
	<?php if( ($this->session->userdata('user_pos')== $this->config->item('ta')) || ($this->session->userdata('user_pos')== $this->config->item('ae'))  ) :?>
		<div class="column full fl">
        <div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?='Performance TA'; ?>
		<?=form_dropdown('periode',array('week'=>'Per Week','month'=>'Per Month','3month'=>'Per 3 Month'),$this->session->userdata('performance'),'onChange="frmPerformance.submit()"');?>			
		
		</h2>
			<div class="box-content box-table">
            
			<?php if($this->session->userdata('performance')== 'month'):?>
			<table class="tablebox">
				<thead class="table-header">
                    <tr>
                    <th colspan="1" scope="colgroup"><h5>Status</h5></th>
                    <th colspan="3" scope="colgroup"><h5><?=$month['name1']?></h5></th>
                    <!--<th colspan="2" scope="colgroup"><h5><?='';?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?='';?></h5></th>-->
                    </tr>
					<tr>
                        <th></th>
                        
						<th colspan="2" scope="colgroup"><h5>D</h5></th>
						<th><h5><?='R'; ?></h5></th>
                        
						<!--
                        <th><h5><?=''; ?></h5></th>
						<th><h5><?=''; ?></h5></th>
                        
                        <th><h5><?=''; ?></h5></th>
						<th><h5><?=''; ?></h5></th>
						-->
                       
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                       <tr> 
                        <td class="left"><?php echo '<h5>New Client</h5>'; ?></td>

						<th><?php echo '<h5>Effort TA</h5>'; ?></th>
                        
						<th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 1
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
						<!--
                        <th>
						<?php
							
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php //echo $data; ?></h5>
						</th>
						-->
						
						<!--
						<th rowspan="2">
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                        
						<!--
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php // echo $data; ?></h5>
						</th>
						-->
						
						<!--
						<th rowspan="2">
						<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
                      </tr>
					  -->
                      
                      <tr> 
                        <td></td>
		
						<th><?php echo '<h5>Manajemen</h5>'; ?></th>
                        <th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        <!-- Data -->
                        
						<!--
						<th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                        
						<!--
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
					
                        
                        
                      </tr>
                      
                      <tr> 
                        <td></td>

						<th></th>
                        <th></th>
                        <!-- Data -->
						<th></th>
                        
						<!--
						<th></th>
                        <th></th>
                        <th></th>
                        <th></th>
					    -->
                        
                        
                      </tr>
                      
                      <tr> 
                        <td><?php echo '<h5>Existing Client</h5>'; ?></td>

						<th rowspan="2">
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>1'.$data.'</h5>';
							echo '<h5>'.$data.'</h5>'
						?>
						
						<?php //echo '<h5>0x</h5>'; ?>
						
						</th>
						
						<th>
						
						<?php
							echo '<h5>Cross Selling</h5>'
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
							
						?>
						</th>
						
						<!--
						<th rowspan="2">
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                        
						<!--
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
						<th rowspan="2">
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
                        <th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                      
					  </tr>
					  
					  <tr> 
                        <td></td>

						<th><?php echo '<h5>Repeat Order</h5>'; ?></th>
						<th>
						
						<?php
							//Bulan ke 1
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        
						<!--
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
						<th>
						<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                        
						<!--
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
						<th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
                        <!--<th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							//echo '<h5>cc'.$data.'</h5>';
						?>
						</th>-->
                      
					  </tr>
				</tbody>
			</table>
			<?php endif;?>
			
			
			<?php if($this->session->userdata('performance')== '3month'):?>
			<table class="tablebox">
				<thead class="table-header">
                    <tr>
                    <th colspan="1" scope="colgroup"><h5>Status</h5></th>
                    <th colspan="3" scope="colgroup"><h5><?=$month['name1']?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?=$month['name2']?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?=$month['name3']?></h5></th>
                    </tr>
					<tr>
                        <th></th>
                        
						<th colspan="2" scope="colgroup"><h5>D</h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                        
                        <th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                        
                        <th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                       
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                       <tr> 
                        <td class="left"><?php echo '<h5>New Client</h5>'; ?></td>

						<th><?php echo '<h5>Effort TA</h5>'; ?></th>
                        
						<th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 1
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
						
                        <th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						<th rowspan="2">
						<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                      </tr>
                      
                      <tr> 
                        <td></td>
		
						<th><?php echo '<h5>Manajemen</h5>'; ?></th>
                        <th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        <!-- Data -->
                        
						<th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
					
                        
                        
                      </tr>
                      
                      <tr> 
                        <td></td>

						<th></th>
                        <th></th>
                        <!-- Data -->
						<th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
					
                        
                        
                      </tr>
                      
                      <tr> 
                        <td><?php echo '<h5>Existing Client</h5>'; ?></td>

						<th rowspan="2">
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>1'.$data.'</h5>';
							echo '<h5>'.$data.'</h5>'
						?>
						
						<?php //echo '<h5>0x</h5>'; ?>
						
						</th>
						
						<th>
						
						<?php
							echo '<h5>Cross Selling</h5>'
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
							
						?>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        <th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                      
					  </tr>
					  
					  <tr> 
                        <td></td>

						<th><?php echo '<h5>Repeat Order</h5>'; ?></th>
						<th>
						
						<?php
							//Bulan ke 1
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th>
						<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
						<!--
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
						<th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
                        <!--<th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>cc'.$data.'</h5>';
						?>
						</th>-->
                      
					  </tr>
				</tbody>
			</table>
			<?php endif;?>
			
			
			<?php if(!$this->session->userdata('performance')):?>
			<table class="tablebox">
				<thead class="table-header">
                    <tr>
                    <th colspan="1" scope="colgroup"><h5>Status</h5></th>
                    <th colspan="3" scope="colgroup"><h5><?='Week 1'?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?='Week 2'?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?='Week 3'?></h5></th>
					<th colspan="2" scope="colgroup"><h5><?='Week 4'?></h5></th>
                    </tr>
					<tr>
                        <th></th>
                        
						<th colspan="2" scope="colgroup"><h5>D</h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                        
                        <th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                        
                        <th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
						
						<th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
		
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                       <tr> 
                        <td class="left"><?php echo '<h5>New Client</h5>'; ?></td>

						<th><?php echo '<h5>Effort TA</h5>'; ?></th>
                        
						<th>
						<?php
							//WEEK ke 1
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from Week 1
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 1
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id1']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);		
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
						
                        <th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						<th rowspan="2">
						<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th>
						<?php
							//Bulan ke 4
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',0);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						<th rowspan="2">
						<?php
							//Bulan ke 4
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',0);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
                      </tr>
					  
					  
					 
                      
                      <tr> 
                        <td></td>
		
						<th><?php echo '<h5>Manajemen</h5>'; ?></th>
                        <th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        <!-- Data -->
                        
						<th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id2']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);								
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						
						<th>
						<?php
							//Bulan ke 4
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',0);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);								
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
					
                        
                        
                      </tr>
                      
                      <tr> 
                        <td></td>

						<th></th>
                        <th></th>
                        <!-- Data -->
						<th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
					
                        <th></th>
                        <th></th>
                        
                      </tr>
                      
                      <tr> 
                        <td><?php echo '<h5>Existing Client</h5>'; ?></td>

						<th rowspan="2">
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							//$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>1'.$data.'</h5>';
							echo '<h5>'.$data.'</h5>'
						?>
						
						<?php //echo '<h5>0x</h5>'; ?>
						
						</th>
						
						<th>
						
						<?php
							echo '<h5>Cross Selling</h5>'
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
							
						?>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							//$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id2']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);								
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        <th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						
						<th rowspan="2">
						<?php
							//Bulan ke 4
							if($this->session->userdata('user_pos')==$this->config->item('ta'))
								$this->db->where('rev',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('se'))
								$this->db->where('rev2',$this->session->userdata('user_id'));
							elseif($this->session->userdata('user_pos')==$this->config->item('ae'))
								$this->db->where('rev3',$this->session->userdata('user_id'));	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							//$this->db->where('MONTH(date_stamp)',0);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        <th>
							<?php
							//Bulan ke 4
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',0);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                      
					  </tr>
					  
					  <tr> 
                        <td></td>

						<th><?php echo '<h5>Repeat Order</h5>'; ?></th>
						<th>
						
						<?php
							//Bulan ke 1
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							//$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							//$this->db->where('MONTH(date_stamp)',$month['id2']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);								
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th>
						<?php
							//Bulan ke 3
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							//$this->db->where('MONTH(date_stamp)',$month['id3']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);		
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th>
						<?php
							//Bulan ke 4
							$this->db->where('pic',$this->session->userdata('user_id'));
							$this->db->where('order_type','Repeat Order');
							//$this->db->where('MONTH(date_stamp)',0);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);								
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
					  </tr>
				</tbody>
			</table>
			<?php endif;?>
			
			</div>
		</div>
       
    </div>
	
	<?=form_close();?>
	
	<!-- Performance TA For SPV -->
	<?php elseif(($this->session->userdata('user_pos')==$this->config->item('spv')) || ($this->session->userdata('user_pos')==$this->config->item('mgr')) ) :?>
	
	<?php //$x=1;?>
	<?php //foreach($table['allUsers'] as $user): ?>
	<div class="column full fl">
        <div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header">
		
		<select name="user" onChange="frmPerformance.submit()" >
			<?php $x=1;?>
			<?php foreach($table['allUsers'] as $user): ?>
				<?php
					if($this->session->userdata('user')==$user['username'])
						$selected = 'selected="selected"';
					else
						$selected = '';
				?>
				<option <?=$selected;?> value="<?=$user['username'];?>"><?=$user['username'];?></option>
			<?php $x++;?>	
			<?php endforeach;?>
		</select>
		<?php 
			if(!$this->session->userdata('user')):
				$user['username']='TA5';
			else:
				$user['username']=$this->session->userdata('user');
			endif;	
		?>
		
		<?=form_dropdown("periode$x",array('week'=>'Per Week','month'=>'Per Month','3month'=>'Per 3 Month'),$this->session->userdata("performance$x"),'onChange="frmPerformance.submit()"');?>			
		<?=anchor('dashboard/crm/exportperformance/'.$user['username'].'/'.$this->session->userdata("performance$x"),'Export to Excel','style="color:#FFF"'); ?>
		</h2>
			<div class="box-content box-table">
            
			<?php if($this->session->userdata("performance$x")== 'month'):?>
			<table class="tablebox">
				<thead class="table-header">
                    <tr>
                    <th colspan="1" scope="colgroup"><h5>Status</h5></th>
                    <th colspan="3" scope="colgroup"><h5><?=$month['name1']?></h5></th>
                    <!--<th colspan="2" scope="colgroup"><h5><?='';?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?='';?></h5></th>-->
                    </tr>
					<tr>
                        <th></th>
                        
						<th colspan="2" scope="colgroup"><h5>D</h5></th>
						<th><h5><?='R'; ?></h5></th>
                        
						<!--
                        <th><h5><?=''; ?></h5></th>
						<th><h5><?=''; ?></h5></th>
                        
                        <th><h5><?=''; ?></h5></th>
						<th><h5><?=''; ?></h5></th>
						-->
                       
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                       <tr> 
                        <td class="left"><?php echo '<h5>New Client</h5>'; ?></td>

						<th><?php echo '<h5>Effort TA</h5>'; ?></th>
                        
						<th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 1
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
						<!--
                        <th>
						<?php
							
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php //echo $data; ?></h5>
						</th>
						-->
						
						<!--
						<th rowspan="2">
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                        
						<!--
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php // echo $data; ?></h5>
						</th>
						-->
						
						<!--
						<th rowspan="2">
						<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
                      </tr>
					  -->
                      
                      <tr> 
                        <td></td>
		
						<th><?php echo '<h5>Manajemen</h5>'; ?></th>
                        <th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        <!-- Data -->
                        
						<!--
						<th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
								
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                        
						<!--
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
					
                        
                        
                      </tr>
                      
                      <tr> 
                        <td></td>

						<th></th>
                        <th></th>
                        <!-- Data -->
						<th></th>
                        
						<!--
						<th></th>
                        <th></th>
                        <th></th>
                        <th></th>
					    -->
                        
                        
                      </tr>
                      
                      <tr> 
                        <td><?php echo '<h5>Existing Client</h5>'; ?></td>

						<th rowspan="2">
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>1'.$data.'</h5>';
							echo '<h5>'.$data.'</h5>'
						?>
						
						<?php //echo '<h5>0x</h5>'; ?>
						
						</th>
						
						<th>
						
						<?php
							echo '<h5>Cross Selling</h5>'
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
							
						?>
						</th>
						
						<!--
						<th rowspan="2">
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                        
						<!--
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
						<th rowspan="2">
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
                        <th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                      
					  </tr>
					  
					  <tr> 
                        <td></td>

						<th><?php echo '<h5>Repeat Order</h5>'; ?></th>
						<th>
						
						<?php
							//Bulan ke 1
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        
						<!--
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
						<th>
						<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
                        
						<!--
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
						<th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
                        <!--<th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							//echo '<h5>cc'.$data.'</h5>';
						?>
						</th>-->
                      
					  </tr>
				</tbody>
			</table>
			<?php endif;?>
			
			
			<?php if($this->session->userdata("performance$x")== '3month'):?>
			<table class="tablebox">
				<thead class="table-header">
                    <tr>
                    <th colspan="1" scope="colgroup"><h5>Status</h5></th>
                    <th colspan="3" scope="colgroup"><h5><?=$month['name1']?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?=$month['name2']?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?=$month['name3']?></h5></th>
                    </tr>
					<tr>
                        <th></th>
                        
						<th colspan="2" scope="colgroup"><h5>D</h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                        
                        <th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                        
                        <th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                       
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                       <tr> 
                        <td class="left"><?php echo '<h5>New Client</h5>'; ?></td>

						<th><?php echo '<h5>Effort TA</h5>'; ?></th>
                        
						<th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 1
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
						
                        <th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						<th rowspan="2">
						<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                      </tr>
                      
                      <tr> 
                        <td></td>
		
						<th><?php echo '<h5>Manajemen</h5>'; ?></th>
                        <th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        <!-- Data -->
                        
						<th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
					
                        
                        
                      </tr>
                      
                      <tr> 
                        <td></td>

						<th></th>
                        <th></th>
                        <!-- Data -->
						<th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
					
                        
                        
                      </tr>
                      
                      <tr> 
                        <td><?php echo '<h5>Existing Client</h5>'; ?></td>

						<th rowspan="2">
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>1'.$data.'</h5>';
							echo '<h5>'.$data.'</h5>'
						?>
						
						<?php //echo '<h5>0x</h5>'; ?>
						
						</th>
						
						<th>
						
						<?php
							echo '<h5>Cross Selling</h5>'
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
							
						?>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        <th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                      
					  </tr>
					  
					  <tr> 
                        <td></td>

						<th><?php echo '<h5>Repeat Order</h5>'; ?></th>
						<th>
						
						<?php
							//Bulan ke 1
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th>
						<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
						<!--
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
						<!--
						<th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						-->
						
                        <!--<th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>cc'.$data.'</h5>';
						?>
						</th>-->
                      
					  </tr>
				</tbody>
			</table>
			<?php endif;?>
			
			
			<?php if(!$this->session->userdata("performance$x")):?>
			<table class="tablebox">
				<thead class="table-header">
                    <tr>
                    <th colspan="1" scope="colgroup"><h5>Status</h5></th>
                    <th colspan="3" scope="colgroup"><h5><?='Week 1'?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?='Week 2'?></h5></th>
                    <th colspan="2" scope="colgroup"><h5><?='Week 3'?></h5></th>
					<th colspan="2" scope="colgroup"><h5><?='Week 4'?></h5></th>
                    </tr>
					<tr>
                        <th></th>
                        
						<th colspan="2" scope="colgroup"><h5>D</h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                        
                        <th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
                        
                        <th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
						
						<th><h5><?php echo 'D'; ?></h5></th>
						<th><h5><?php echo 'R'; ?></h5></th>
		
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                       <tr> 
                        <td class="left"><?php echo '<h5>New Client</h5>'; ?></td>

						<th><?php echo '<h5>Effort TA</h5>'; ?></th>
                        
						<th>
						<?php
							//WEEK ke 1
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from Week 1
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 1
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id1']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);		
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
						
                        <th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
								
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						<th rowspan="2">
						<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th>
						<?php
							//Bulan ke 4
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							$this->db->where('customer_from','Mandiri');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',0);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
						?>
						<h5><?php echo $data; ?></h5>
						</th>
						<th rowspan="2">
						<?php
							//Bulan ke 4
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',0);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
                      </tr>
					  
					  
					 
                      
                      <tr> 
                        <td></td>
		
						<th><?php echo '<h5>Manajemen</h5>'; ?></th>
                        <th>
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        <!-- Data -->
                        
						<th>
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id2']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);								
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						
						<th>
						<?php
							//Bulan ke 4
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);	
							//customer_from
							$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('prospect'));
							//$this->db->where('MONTH(date_stamp)',0);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);								
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
					
                        
                        
                      </tr>
                      
                      <tr> 
                        <td></td>

						<th></th>
                        <th></th>
                        <!-- Data -->
						<th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
					
                        <th></th>
                        <th></th>
                        
                      </tr>
                      
                      <tr> 
                        <td><?php echo '<h5>Existing Client</h5>'; ?></td>

						<th rowspan="2">
						<?php
							//Bulan ke 1
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							//$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							//echo '<h5>1'.$data.'</h5>';
							echo '<h5>'.$data.'</h5>'
						?>
						
						<?php //echo '<h5>0x</h5>'; ?>
						
						</th>
						
						<th>
						
						<?php
							echo '<h5>Cross Selling</h5>'
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
							
						?>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 2
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							//$this->db->where('MONTH(date_stamp)',$month['id2']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id2']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);								
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th rowspan="2">
						<?php
							//Bulan ke 3
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        <th>
							<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',$month['id3']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						
						<th rowspan="2">
						<?php
							//Bulan ke 4
							if($this->session->userdata('user_group')==$this->config->item('user'))
								$this->db->where('rev',$user['username']);
							elseif($this->session->userdata('user_group')==$this->config->item('user_dna'))
								$this->db->where('rev3',$user['username']);		
							//customer_from
							//$this->db->where('customer_from','Manajemen');
							$this->db->where('status_id',$this->config->item('existing'));
							//$this->db->where('MONTH(date_stamp)',0);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);	
							$Q=$this->db->get('customers');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        <th>
							<?php
							//Bulan ke 4
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','First Order');
							//$this->db->where('MONTH(date_stamp)',0);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                      
					  </tr>
					  
					  <tr> 
                        <td></td>

						<th><?php echo '<h5>Repeat Order</h5>'; ?></th>
						<th>
						
						<?php
							//Bulan ke 1
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							//$this->db->where('MONTH(date_stamp)',$month['id1']);	
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',1);	
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							
							echo '<h5>'.$data.'</h5>';
						?>
						
						</th>
                        
                        <th>
						<?php
							//Bulan ke 2
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							//$this->db->where('MONTH(date_stamp)',$month['id2']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',2);								
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th>
						<?php
							//Bulan ke 3
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							//$this->db->where('MONTH(date_stamp)',$month['id3']);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',3);		
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
						
						<th>
						<?php
							//Bulan ke 4
							$this->db->where('pic',$user['username']);
							$this->db->where('order_type','Repeat Order');
							//$this->db->where('MONTH(date_stamp)',0);
							$this->db->where('(WEEK(date_stamp, 5) - WEEK(DATE_SUB(date_stamp, INTERVAL DAYOFMONTH(date_stamp) - 1 DAY), 5) + 0)=',4);								
							$Q=$this->db->get('jobs');
							$data=$Q->num_rows();
							echo '<h5>'.$data.'</h5>';
						?>
						</th>
                        
					  </tr>
				</tbody>
			</table>
			<?php endif;?>
			
			</div>
		</div>
       
    </div>
	
	<?php 
		//$x++;
		//endforeach; ?>
	
	<?php endif;?>
<?php endif;?>


<?php if(($this->session->userdata('user_pos')== $this->config->item('spv')) ):?> 
<div class="column full fl">
  
        <div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?='Weekly Report';?></h2>
			
			<div class="box-content box-table">
			
            <?php echo $this->session->flashdata('messagex'); ?>
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                       <th><?='User'?></th>
					   <th><?='Week I'?></th>
					   <th><?='Week II'?></th>
					   <th><?='Week III'?></th>
					   <th><?='Week IV'?></th>
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                    <?php $i=1; ?>
					<?php foreach($table['allUsers'] as $rec): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?php echo $rec['username']; ?>
						</td>
						<td class="tc">
							<?=anchor('dashboard/crm/exportweekly/'.$rec['username'].'/1','Export','style="color:#222"');?>
						</td>
						
						<td class="tc">
							<?=anchor('dashboard/crm/exportweekly/'.$rec['username'].'/2','Export','style="color:#222"');?>
						</td>
						
						<td class="tc">
							<?=anchor('dashboard/crm/exportweekly/'.$rec['username'].'/4','Export','style="color:#222"');?>
						</td>
						
						<td class="tc">
							<?=anchor('dashboard/crm/exportweekly/'.$rec['username'].'/4','Export','style="color:#222"');?>
						</td>
						
					</tr>
                    <?php $i++; 
					endforeach;?>
				</tbody>
			</table>
			</div>
		</div>
       	  
 </div>
 <?php endif;?>
 


<!--batas-->
<div class="column half fl">
   <?php if( ($this->session->userdata('user_group')==$this->config->item('admin'))):?> 
        <div class="box themed_box">
		<h2 class="box-header-new"></h2>
		<h2 class="box-header"><?php echo $grid['grid1']; ?></h2>
			
			<div class="box-content box-table">
			
            <?php echo $this->session->flashdata('message'); ?>
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                       <th><?php echo $this->lang->line('date'); ?></th>
					   <th><?php echo $this->lang->line('cust_name'); ?></th>
						<th class="tc"><?php echo $this->lang->line('pic'); ?></th>
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                    <?php $i=1; ?>
					<?php foreach($table['customers'] as $rec): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td class="tc">
							<?php echo $rec['activity_date']; ?>
						</td>
						<td >
							<h5><?php echo $rec['customer_name']; ?></h5>
						</td>
						
					</tr>
                    
					<tr class="odd openable-tr">
						
                        <td colspan="4">
							<div class="fl typo">
							<b><?php $this->config->item('customer'); ?></b>
							<p class="p_justify">
                              <?php echo $rec['tlp']; ?>
							</p>
							<div class="s_3"></div>
							<p class="p_justify">
                              <?php echo $rec['pic']; ?>
							</p>
							</div>
						   <!--
							<div class="fr">
								 <input id="validate" class="button themed" type="submit" value="<?php echo $this->lang->line('save');?>" name="save" />
							</div>
						   -->
						<div class="clear"></div>
						</td>
					</tr>
                    <?php $i++; endforeach;?>
				</tbody>
			</table>
			</div>
		</div>
        
        <?php endif;?>
        
        <?php if( ($this->session->userdata('user_group')==$this->config->item('admin'))):?>
        <?php if( ($this->session->userdata('user_group')==$this->config->item('admin')) || ($this->session->userdata('user_group')==$this->config->item('user')) ) : ?>
         <div class="box tabs themed_box">
			<h2 class="box-header"><?php echo $grid['grid2'];?></h2>

		
			<div class="box-content">
			
			
				<table id="table" style="display:none" >

				<caption><?php echo date('M-Y'); ?></caption>
				<thead>
					<tr>
						<td></td>
                        <?php foreach($table['type'] as $type): ?>		
						<th><?php echo $type['activity_type'].'.T';?></th>
                        <th><?php echo $type['activity_type'];?></th>
                        <?php endforeach; ?>
					</tr>
				</thead>
				<tbody>
					
                    <?php foreach($table['users'] as $user): ?>
                    <tr>
                    
						<th><?php echo $user['username']; ?></th> 
                        <?php foreach($table['type'] as $type): ?> 
						<td><?php echo $type['target']; ?></td>
                        <?php $this->db->select('COUNT(activity_id) as total'); ?>
                        <?php $this->db->where('activity_id',$type['id']); ?>
                        <?php $this->db->where('MONTH(activity_date)',date('m')); ?>
                        <?php $this->db->where('pic',$user['username']); ?>
                        <?php $Q=$this->db->get('activity_transaction',$user['username']); ?>
                        <?php $rows=$Q->row_array(); ?>
                        <td><?php echo $rows['total'];?></td>
						<?php endforeach; ?>
                    </tr>
                    <?php endforeach;?>  
                    
          
                    			
				</tbody>
		</table>
		<br/><br/>
			
			
			
			</div>
		</div>
        <?php endif;?>
        <?php endif;?>
		  
        </div>
        
    <div class="column half fr"> 
    <?php if( ($this->session->userdata('user_group')==$this->config->item('admin'))):?> 
    <div class="box themed_box">
		
		<h2 class="box-header"><?php echo $grid['grid3']; ?></h2>
			
			<div class="box-content box-table">
			
            
            
			<table class="tablebox">
				<thead class="table-header">
					<tr>
                        <th><?php echo $this->lang->line('date'); ?></th>
						<th><?php echo $this->lang->line('name'); ?></th>
						<th><?php echo $this->lang->line('pic'); ?></th>
						<th class="tc"></th>
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                    
                    <?php $i=1; ?>
					<?php foreach($table['activity_transaction'] as $rec): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td>
							<h5><?php echo $rec['activity_date']; ?></h5>
		
						</td>
                        <td >
							<?php echo $rec['customer_name']; ?>
		
						</td>
						<td class="tc">

							<?php echo $rec['pic']; ?>
						</td>
				   </tr>
                   <?php endforeach;?>		
				</tbody>
			</table>
            
			</div>
		</div>
        
        <?php endif;?>
		  
		  <?php if( ($this->session->userdata('user_group')==$this->config->item('admin'))):?>
		  <?php if( ($this->session->userdata('user_group')==$this->config->item('admin')) || ($this->session->userdata('user_group')==$this->config->item('user')) ) : ?>
          <div class="box themed_box">
            <h2 class="box-header"><?php echo $this->lang->line('jo_report');?></h2>

            <div class="box-content">
            <?php //echo $table['totalJO']['total']; ?>
              <?php if($table['totalJO']['total']>0): ?>
              <table id="table2" style="display:none" >
				<caption><?php echo date('M-Y').'-'.'Skala 1:100.000'; ?></caption>
				<thead>
					<tr>
						<td>Username</td>
                        <?php //foreach($table['users'] as $user): ?>		
						<th><?php echo 'Nilai';?></th>
                        <?php //endforeach; ?>
					</tr>
				</thead>
				<tbody>
					
                    <tr>
                     <?php foreach($table['users'] as $user): ?>
						<?php foreach($table['jo'] as $jo): ?>
						    <?php if($jo['username']==$user['username']): ?>
							<th><?php echo $user['username'].'-'.$jo['total']/100000;?></th>
							<?php endif;?>		
							 <?php endforeach; ?>
                        <?php foreach($table['jo'] as $jo): ?>
						<?php if($jo['username']==$user['username']): ?>
                        <?php if($jo['total']<>""): ?> 
						
						<td title="10"><?php echo number_format($jo['total']/100000,0, '.', ''); ?></td>
                        <?php  else:?>
                        <td><?php echo '0'; ?></td>
                        <?php endif;?>
						<?php endif;?>
						<?php endforeach; ?>
                    </tr>
					<?php  endforeach; ?>	
          
                    			
				</tbody>
		</table>
        <?php endif;?>
         <?php endif;?>
        <br />
        <br />
              
              

            </div>
          </div>
          <?php endif;?>
          
        </div>

<!--batas-->


<?php if(($this->session->userdata('user_pos')==$this->config->item('ta'))): ?>
<?php //if(($this->session->userdata('user_group')==$this->config->item('user')) ): ?>
<script type="text/javascript">
	$(function() {
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
	    $( "#dialog-message2" ).dialog({ width: 800 });
		$( "#dialog-message2" ).dialog({
			modal: true,
			buttons: {
				Ok: function() {
					$( this ).dialog( "close" );
				}
			}
		});
	});
</script>

<!---
<div class="demo">

<div  id="dialog-message2" title="<?php echo $grid['grid3']; ?>">
	<table class="tablebox">
				<thead class="table-header">
					<tr>
                        <th><?php echo $this->lang->line('date'); ?></th>
						<th><?php echo $this->lang->line('name'); ?></th>
						<th><?php echo $this->lang->line('pic'); ?></th>
						<th class="tc"></th>
					</tr>
				</thead>
				
				<tbody class="openable-tbody">
                    <?php $i=$i+1; ?>
					<?php foreach($table['activity_transaction'] as $rectrans): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
                    <tr class="<?php echo $zebra;?>">
						<td>
							<h5><?php echo $rectrans['activity_date']; ?></h5>
		
						</td>
                        <td >
							<?php echo $rectrans['customer_name']; ?>
		
						</td>
						<td class="tc">

							<?php echo $rectrans['pic']; ?>
						</td>
						<td class="tc">
						
                        </td>
					</tr>
                    <?php $i++; endforeach;?> 
                    
				</tbody>
			</table>
</div>

</div>
End demo -->
 <?php endif;?>
<?php //endif;?>
		
